﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HpControl : MonoBehaviour
{
    [SerializeField]
    private float speed = 3f;
    
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        transform.Rotate(0,speed,0);
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Player"))
        {
            //加血
            Debug.Log("加血");
            Actor target = other.gameObject.GetComponent<Actor>();
            if (target.networkId.Equals(Game.GetComp<ActorManager>().controlPlayerId))
            {
                target.propertyComponent.CmdTakeDamage(target.networkId, 20);
            }
            //销毁
            Destroy(gameObject);
        }
    }
}
